let index_fn = async (ctx, next) => {
    ctx.body = `
    <h1>欢迎光临，请登录您的账号！</h1>
    <form action="/login" method="post">
    <table>
        <div>
            <label for="">账号：</label>
            <input type="text" name="username">
        </div>
        <div>
            <label for="">密码：</label>
            <input type="password" name="password">
        </div>
        <div>
            <input type="submit" value="登录">
        </div>
    </table>
</form>
    `
}

let login_fn=async (ctx,next)=>{
    let username = ctx.request.body.username || '';
    let password = ctx.request.body.password || '';
    if(username === 'admin' && password === '123'){
        ctx.response.body='今日天气：21°~31°';
       
    }
    else{
        ctx.response.body = '账号或密码错误！'
    }
}


module.exports = {
    '/':['get',index_fn],
    '/login':['post',login_fn],
}
